﻿
namespace KingerRobot.MexicoSailunMDC.SpiService;

internal class BWcsEquipWarehouseDistance : IWcsEquipWarehouseDistance
{
    public List<POWcsEquipWarehouseDistance> GetEquipWarehouseDistance()
    {
        var db = Db.Default;
        var result = db.WcsEquipWarehouseDistances.Where(t => t.UseFlag == 1).ToList();
        return result;
    }
    public List<POWcsEquipWarehouseDistance> GetEquipWarehouseDistanceByCrnId(long crnId)
    {
        var db = Db.Default;;
        var result = db.WcsEquipWarehouseDistances.Where(t => t.UseFlag == 1 && t.CrnId == crnId).ToList();
        return result;
    }
    public List<POWcsEquipWarehouseDistance> GetEquipWarehouseDistanceByWarehouseId(long WarehouseId)
    {
        var db = Db.Default;
        var result = db.WcsEquipWarehouseDistances.Where(t => t.UseFlag == 1 && t.WarehouseId == WarehouseId).ToList();
        return result;
    }
    public int GetCrnToCuringTransTime(long crnId, long curingLocId)
    {
        var db = Db.Default;
        var result = db.WcsEquipWarehouseDistances.Where(t => t.CrnId == crnId && t.CuringLocId == curingLocId).FirstOrDefault()?.Seconds;
        return result.GetValueOrDefault();
    }

}
